//
//  CommentCell.m
//  myhuibao
//
//  Created by li jun on 13-2-28.
//  Copyright (c) 2013年 myhuibao. All rights reserved.
//

#import "BoxCell.h"
#import "BoxPhotoViewController.h"
@implementation BoxCell
@synthesize checked;
@synthesize lbName;
@synthesize lbMemo;
@synthesize lbOther;
@synthesize ivChecked;
@synthesize imageView;
@synthesize image;
@synthesize imagepath;
- (void)setImage:(UIImage *)img {
    if (![img isEqual:image]) {
        image = [img copy];
        self.imageView.image = image;
    }
}
-(void)setChecked:(bool)ck {
    if (ck) {
        ivChecked.image = [UIImage imageNamed:@"Selected.png"];
    }else{
        ivChecked.image = [UIImage imageNamed:@"UnSelected.png"];
    }
}

- (IBAction)showPhotos:(id)sender {
        if (![imagepath isEqual:[NSNull null] ] && imagepath!=NULL) {
            NSArray *aArray = [imagepath componentsSeparatedByString:@","];
            NSMutableArray *photoArray = [[NSMutableArray alloc]init];
            for(int i=0;i<aArray.count-1;i++){
                NSString * defaultImage = [[aArray objectAtIndex:i] stringByReplacingOccurrencesOfString:@"[imageSize]" withString:@""];
                NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
                                      defaultImage,@"image",nil];
                [photoArray addObject:dict];
                
            }
            BoxPhotoViewController  *view = [[BoxPhotoViewController alloc] initWithNibName:@"BoxPhotoViewController" bundle:nil];
            
            view.photoArray = photoArray;
            view.mainTitle = lbName.text;
            view.hidesBottomBarWhenPushed=YES;
            [[self viewController].navigationController pushViewController:view animated:YES];
            
    }
    
}
- (UIViewController*)viewController {
    for (UIView* next = [self superview]; next; next = next.superview) {
        UIResponder* nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController*)nextResponder;
        }
    }
    return nil;
}

@end
